from django import forms
from django.template.context_processors import request

from web import models
from web.forms.bootstrap import BootStrapForm

class WikiModelForm(BootStrapForm, forms.ModelForm):

    class Meta:
        model = models.WiKi
        exclude = ['project',]

    def __init__(self, request,*args, **kwargs):
       super().__init__(self,*args, **kwargs)
        # 找到想要的字段把它绑定显示的数据重置
       total_data_list = ["","请选择",]
       data_list = models.WiKi.objects.filter(prject=request.tracer.project).values_list('id','title')
       total_data_list.extend(data_list)
       self.fields['parent'].choices = total_data_list


